﻿
<template>
    <div>
        <el-select placeholder="请选择系部" v-if="!dx" size="mini" v-model="pzoption.value" class="form-control filter" style="height: 34px;padding:0px">
            <el-option v-for="item in xbdata" :key="item.xbdm" :label="item.xbmc" :value="item.xbdm">
            </el-option>
        </el-select>
        <el-select placeholder="请选择系部" v-if="dx" size="mini" v-model="pzoption.value" class="form-control filter" style="height: 34px;padding:0px" multiple collapse-tags>
            <el-option v-for="item in xbdata" :key="item.xbdm" :label="item.xbmc" :value="item.xbdm">
            </el-option>
        </el-select>
    </div>
</template>

<script>
    module.exports = {
        props: ['pzoption', 'isjx', 'isqx', 'isdx', 'iskc'],
        data() {
            return {
                xbdata: [],
            };
        },
        computed: {
            dx: function () {
                return this.isdx == "";
            }
        },
        methods: {

        },
        watch: {

        },
        mounted: function () {
            var chi = this;
            chi.$nextTick(function () {
                var tempxbdata = JSON.parse(localStorage.getItem("xbdata"));
                var xbdata = [];
                if (this.isqx == "") {
                    //先过滤掉没有权限的
                    _.forEach(tempxbdata, function (obj) {
                        if (obj.qxxb == '1') {
                            xbdata.push(obj);
                        }
                    })
                } else {
                    xbdata = tempxbdata;
                }
                var temp = [];
                if (this.isjx == "") {
                    _.forEach(xbdata, function (obj) {
                        if (obj.jxxb) {
                            temp.push(obj);
                        }
                    })
                }
                else {
                    temp = xbdata;
                }

                var templast = [];
                if (this.iskc == "") {
                    _.forEach(temp, function (obj) {
                        if (obj.kcxb=='1') {
                            templast.push(obj);
                        }
                    })
                }
                else {
                    templast = temp;
                }
                chi.xbdata = templast;
                if (chi.xbdata.length > 0) {
                    if (chi.dx) {
                        _.forEach(chi.xbdata, function (obj) {
                            chi.pzoption.value.push(obj.xbdm);
                        })   
                       
                    } else {
                        chi.pzoption.value = chi.xbdata[0].xbdm;

                    }
                }
            })

        }
    };
</script>